#include "stdafx.h"

class Complex 
{
public:
	Complex( double real, double imaginary = 0 )
		: _real(real), _imaginary(imaginary)
	{
	}
	void operator+ ( Complex other )
	{
		_real = _real + other._real;
		_imaginary = _imaginary + other._imaginary;
	}
	void operator<<( ostream os )
	{
		os << "(" << _real << "," << _imaginary << ")";
	}
	Complex operator++()
	{
		++_real;
		return *this;
	}
	Complex operator++( int )
	{
		Complex temp = *this;
		++_real;
		return temp;
	}
	//private:
	double _real, _imaginary;
};

class Complex2 
{
public:
	explicit Complex2( double real, double imaginary = 0 )
		: _real(real), _imaginary(imaginary)
	{
	}
	Complex2& operator+=(const Complex2& other)
	{
		_real += other._real;
		_imaginary += other._imaginary;
		return *this;
	}
	const Complex2& operator++()
	{
		++_real;
		return *this;
	}
	const Complex2 operator++(int)
	{
		Complex2 temp(*this);
		++*this;
		return temp;
	}
	ostream& print(ostream& os ) const
	{
		os << "(" << _real << "," << _imaginary << ")";
		return os;
	}
private:
	double _real, _imaginary;
};

const Complex2 operator+ (const Complex2& lhs, const Complex2& rhs )
{
	Complex2 ret(lhs);
	ret += rhs;
	return ret;
}

ostream& operator<<( ostream& os, const Complex2& c )
{
	return c.print(os);
}

void f(Complex x)
{

}
void f2(Complex2 x)
{

}
TEST(classes, mechanics1)
{
	Complex c1(1.0);
	Complex c12(2.0);
	f(1.0);
	//Complex c13 = c1 + c12;
	c1 + c12;
	EXPECT_EQ(3.0, c1._real);

	c1++++++++++;//-.-!
	//cout<<c1;
	//c1 += c12;

	Complex2 c2(1.0);
	Complex2 c21(2.1);
	//f2(1.0);
	Complex2 c22 = c2 + c21;
	//c2++++;
	cout<<c2<<endl;
	c2 += c21;
}